<?php
session_start();
$openid=NULL;
if (isset($_GET['op'])){
    $openid=$_GET['op'];
    $_SESSION['openid']=$openid;
}
if (isset($_SESSION['openid'])){
    $openid=$_SESSION['openid'];
}
if (empty($openid)){
    echo '请关闭当前页面，重写进入';
    exit;
}
include_once("./c/config.php");
$userInfo=array();
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
$query=$mysqli->query("select name,phone,hao from u3 where openid='".$openid."' limit 0, 1");
$hasU=2;
$name=$phone=$hao='';
if($query->num_rows>0){
    $hasU=1;
    $getU=$query->fetch_array();
    $name=$getU['name'];
    $phone=$getU['phone'];
    $hao=$getU['hao'];
}

$query=$mysqli->query("SELECT count(id) as count FROM `ci3` where openid='".$openid."' ");
$getCount=$query->fetch_assoc();
$count=$getCount['count']+1;
$_SESSION['cishu']=$count;

$url=$urlB='./';
$url=$urlB='http://tu-10030004.file.myqcloud.com/zhong/';
$_SESSION['skey']=rand(1,99999999);
$mysqli->close();
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<title>中国诗词大会</title>
<style>
html,body{font-size:16px;width:100%;font-size:12px;color:#fff;font-family:Microsoft YaHei, Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;}
body, div{position:relative;padding:0px;margin:0px auto;max-width:750px;}
.weui-dialog{position:fixed;z-index:5000;width:80%;max-width:300px;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background-color:#FFF;text-align:center;border-radius:3px;overflow:hidden}.weui-dialog__hd{padding:1.3em 1.6em .5em}.weui-dialog__title{font-weight:400;font-size:18px}.weui-dialog__bd{padding:0 1.6em .8em;min-height:40px;font-size:15px;line-height:1.3;word-wrap:break-word;word-break:break-all;color:#999}.weui-dialog__bd:first-child{padding:1.2em 20px .1em;color:#353535}.weui-dialog__ft{position:relative;line-height:48px;font-size:18px;display:-webkit-box;display:-webkit-flex;display:flex}.weui-dialog__ft:after{content:" ";position:absolute;left:0;top:0;right:0;height:1px;border-top:1px solid #D5D5D6;color:#D5D5D6;-webkit-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.weui-dialog__btn{display:block;-webkit-box-flex:1;-webkit-flex:1;flex:1;color:#3CC51F;text-decoration:none;-webkit-tap-highlight-color:transparent;position:relative}.weui-dialog__btn:active{background-color:#EEE}.weui-dialog__btn:after{content:" ";position:absolute;left:0;top:0;width:1px;bottom:0;border-left:1px solid #D5D5D6;color:#D5D5D6;-webkit-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleX(.5);transform:scaleX(.5)}.weui-dialog__btn:first-child:after{display:none}.weui-dialog__btn_default{color:#353535}.weui-dialog__btn_primary{color:#0BB20C}@media screen and (min-width:1024px){.weui-dialog{width:35%}}.weui-mask{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0;background:rgba(0,0,0,.6)}.weui-mask_transparent{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0}
-webkit-touch-callout:none;
-webkit-user-select:none;
html{-ms-touch-action:none;}
*{-webkit-overflow-scrolling:touch;}
.fixfixed {position:absolute;}
div,img{-webkit-tap-highlight-color:rgba(0,0,0,0);}
*{-webkit-text-size-adjust: none;}
.simg{position:absolute;display:block;}
a{text-decoration:none;}
.txt{position:absolute;text-indent:6px;font-size:12px;z-index:2;}
.txt::-webkit-input-placeholder {color:#b4b4b4;text-align:left;}
.container{position:relative;width:100%;height:auto;overflow:hidden;}
.p1, .qu, .p3, .p2, .p4{position:absolute;width:100%;height:100%;display:none;}
.p1{background:#f5f3e9;} 
input{position:absolute;display:block;text-indent:10px;-webkit-appearance:none;background:none;padding:0;outline-style:none;border:none;color:#000;}
select{position:absolute;display:block;background:transparent;border:0px;text-indent:8px;font-size:12px;-webkit-appearance:none;}

.a100{position:absolute;display:block;width:100%;left:0;}
 
.t-rule, .t-zhuyi, .ti{position:absolute;width:100%;z-index:99;top:0px;left:0px;display:none;}
.t-end, .t-wan{position:absolute;width:100%;z-index:9999;top:0px;left:0px;display:none;}
.p-b, .thebg{position:absolute;width:100%;top:0;left:0;} 
#iosDialog2{display:none;}
.p1-top{position:absolute;width:100%;display:block;top:0;left:0;}
.p1-t1{background:transparent url('<?php echo $urlB; ?>img4/p1-t1.png') no-repeat;background-size:cover;}
.p1-t2{position:absolute;width:100%;display:block;bottom:0;left:0;}
.p4-down{position:absolute;width:100%;}
.p4-shi, .p4-fen, .p4-miao{position:absolute;font-size:16px;color:#333333;font-weight:700;text-align:right;}
.t-bg, .t-bg2{position:absolute;width:100%;height:100%;background-color:#000000;opacity:.9;top:0px;left:0px;}
.t-bg{display:none;z-index:9;}
.hide{display:none;}
.p4-t3 img{display:block;width:100%;}

 
.p2-s1{position:absolute;background:transparent url('<?php echo $urlB; ?>img3/school.png') no-repeat;background-size:cover;}
.p2-s1-2{position:absolute;width:100%;height:100%;left:0;top:0;}
</style>
</head>
<body>
<div class="container">
  <div class="p1 page">
     <img class="p1-top simg " src="<?php echo $urlB; ?>img4/p1-top.jpg">
     
     <img class="p1-t2 simg " src="<?php echo $urlB; ?>img4/p1-t2.jpg">
     <div class="thebg">
         <div class="p1-t1 a100">
            <div class="p1-bao simg"></div>
         </div> 
     </div>
  </div> 

  
  
  <div class="p2">
      <img class="bg simg" src="<?php echo $urlB; ?>img4/b.jpg">
      
      <div class="thebg">
         <img class="p-b simg" src="<?php echo $urlB; ?>img4/p2.png?v=4">
         

         <input id="p2-name" class="txt" name="name"  type="text" value="<?php echo $name ?>" placeholder="请填写姓名"  />
		 <input id="p2-phone" class="txt" name="phone" type="number" value="<?php echo $phone ?>" placeholder="请填写本人手机号码"  />
          
		 <input id="p2-hao" class="txt" name="hao" type="text" value="<?php echo $hao ?>" placeholder="请填写本人身份证号"  />
  
         <div class="p2-jin simg"></div>
      </div>
  
  </div>
  
  <div class="p3">
      <img class="bg simg" src="<?php echo $urlB; ?>img4/b.jpg">
      <div class="thebg">
         <img class="p3-t1 a100" src="<?php echo $urlB; ?>img4/p3.png">
         <div class="p3-t2 simg"></div>
      </div>
  </div>
  
  <div class="p4">
      <img class="bg simg" src="<?php echo $urlB; ?>img3/p4.jpg">
      <img class="p4-t1 a100" src="<?php echo $urlB; ?>img3/p4-t1.jpg">
      <div class="p4-t3">
            <img src="<?php echo $urlB; ?>img3/p4-txt.png"><br />
      </div>
  
     <img class="p4-b1 simg" src="<?php echo $urlB; ?>img3/p4-b1.png">
  </div>
 
   
  <div class="js_dialog" id="iosDialog2" style="opacity: 1;">
       <div class="weui-mask"></div>
       <div class="weui-dialog">
                <div class="weui-dialog__bd weui-msg"></div>
                <div class="weui-dialog__ft">
                    <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary weui-btn">知道了</a>
                </div>
        </div>
 </div>
  
</div>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="<?php echo $url; ?>/js/pxloader-images.min.js"></script>
<script src="<?php echo $url; ?>/js/jquery.countdown.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
var _hasU='<?php echo $hasU; ?>';
h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
var _rate=(sWidth/750);
if(h<_rate*1206){
	h=_rate*1206;
}
var _img=['p1-top.jpg'];
var loader = new PxLoader();
for(var i=0; i<_img.length; i++){loader.addImage('<?php echo $urlB; ?>/img4/'+_img[i]);}
loader.start();
loader.addCompletionListener(function(e) {
    
     $(".p1").show();
     
});

function fixScroll(){
    let u = navigator.userAgent;
    let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isiOS) {
      window.scrollTo(0, 0);
    }
 }
$("input, select").blur(function(){
	fixScroll()
});
var _fdes='<?php echo $openid; ?>';
$(function(){
	$('.container, .bg, .page').width(sWidth).height(h);
	$('.p1-bg, .rule-t1').width(sWidth).height(_rate*1206);
	$('.thebg, .p-b').width(sWidth).height(_rate*1206);

	$('.p1-t1').height(_rate*552).css({"top":_rate*280});

	$('.p1-bao').width(_rate*460).height(_rate*152).css({"top":_rate*350, "left":_rate*150});
	 
	$('.p3-t1').css({"top":0});
	$('.p3-t2').width(_rate*486).height(_rate*170).css({"top":_rate*780, "left":_rate*120});

	 
	$('.p4-t3').width(_rate*646).height(_rate*720).css({"top":_rate*198, "left":_rate*54});
	$('.p4-b1').width(_rate*549).height(_rate*148).css({"top":_rate*928, "left":_rate*100});
 
	  
	$("#p2-name").width(_rate*372).height(_rate*80).css({"top":_rate*259, "left":_rate*278});
	$("#p2-phone").width(_rate*372).height(_rate*80).css({"top":_rate*388, "left":_rate*278});
	 
	$("#p2-hao").width(_rate*372).height(_rate*80).css({"top":_rate*526, "left":_rate*278});

	 
	
	$(".p2-jin").width(_rate*470).height(_rate*110).css({"top":_rate*736, "left":_rate*142});
     
	 
 
	$('.p1-click').click(function(){
		$(".weui-msg").html("活动已结束");
        $("#iosDialog2").show();
        return;
		$(".p1").hide();
		if(1 == _hasU){
			$(".p3").fadeIn();
		}else{
			$(".p2").fadeIn();
		}
	});
    
	$(".p2-jin").click(function(){
		 var _name=$("#p2-name").val();
		 var _phone=$("#p2-phone").val();
		 var _hao=$("#p2-hao").val();
		  
		 if('' == _name){
             $(".weui-msg").html("请填写姓名");
             $("#iosDialog2").show();
             return;
         }
		 if('' == _phone){
             $(".weui-msg").html("请填写本人手机号码");
             $("#iosDialog2").show();
             return;
         }
		 if(false == checkTel(_phone)){
	 			$(".weui-msg").html("请填写正确的手机号");
	            $("#iosDialog2").show();
	            return;
	     }
	 
	 	if('' == _hao){
            $(".weui-msg").html("请填写本人身份证号");
            $("#iosDialog2").show();
            return;
        }
         $.post("api/?c=bao", {fdes:_fdes,name:_name, phone:_phone
        	 ,  hao:_hao
             }, function(data){
            	 if('h' == data.s){
                 	$(".weui-msg").html("您已参与答题");
     		        $("#iosDialog2").show();
     		        return;
                 }else{
                	 if('time' == data.s){
                		$(".weui-msg").html("还未到开考时间");
          		        $("#iosDialog2").show();
          		        return;
                     }else{
                    	 window.location.href="ti.php";
                     }
                 }
 	     }, "json"); 
         
	});
	 
	function checkTel(tel){
	    return /^1(3|2|4|5|6|7|8|9)[0-9]\d{8}$/.test(tel)
	}
 
	if(h > _rate*1206){
		   var _cha= h - _rate*1246;
		   if(_cha > 0){
			  
		      $('.kai, .t-wan, .t-rule').css({"top":_cha/2});
		      $('.thebg').css({"top":_cha/3});
		    
		   }
      
	}

	function _popMsg(msg){
		$(".weui-msg").html(msg);
        $("#iosDialog2").show();
        return;
    }

	$('.p1-bao').click(function(){
		$(".weui-msg").html("考试已结束");
        $("#iosDialog2").show();
        return;
		$(".p1").fadeOut();
		$(".p3").fadeIn();
	}); 
     $(".p3-t2").click(function(){
    	 $.post("api/?c=gettime", {id:1}, function(data){
             if('k' == data.s){
            	 $(".p3").fadeOut();
         		 $(".p2").fadeIn();
             }else{
            	 if('expire' == data.s){
            		 window.location.href="http://mei94.com/zhong/";
                 }else{
                	 $(".weui-msg").html("还未到开考时间");
     		         $("#iosDialog2").show();
                 }
             }
 	     }, "json"); 
 	      
	});
 
	$(".weui-btn").click(function(){
        $("#iosDialog2").hide();
	});

    
	if(!('placeholder' in document.createElement('input')) ){   
	    $('input[placeholder],textarea[placeholder]').each(function(){var that = $(this),text= that.attr('placeholder');   
	      if(that.val()===""){that.val(text).addClass('placeholder');}   
	      that.focus(function(){if(that.val()===text){that.val("").removeClass('placeholder');}})   
	      .blur(function(){if(that.val()===""){that.val(text).addClass('placeholder');}})   
	      .closest('form').submit(function(){   
	        if(that.val() === text){that.val('');}});});   
	 }

	setCookie("eTimec", '', 1);
	function setCookie(cname, cvalue, exdays) {
	    var d = new Date();
	    d.setTime(d.getTime() + (exdays*24*60*60*1000));
	    var expires = "expires="+ d.toUTCString();
	    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
	}

 
});
</script>
</body>
</html>